package com.sanyang.lawyer.service.hr;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sanyang.lawyer.entity.HrFlexigrid;
import com.sanyang.lawyer.entity.Hr_emp;
import com.sanyang.lawyer.mapper.hr.HrEmpMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HrEmpService {

    @Autowired
    private HrEmpMapper empMapper;

    public Hr_emp getById(int id){
        return empMapper.selectById(id);
    }

    public List<Hr_emp> listALL(Hr_emp emp, Integer page, Integer limit){
        return empMapper.listALL(emp);
    }

    public List<Hr_emp> listALLPage(HrFlexigrid hrFlexigrid) {
        return empMapper.listALLPage(hrFlexigrid);
    }

    public Integer listALLCount(Hr_emp emp) {
        return empMapper.listALLCount(emp);
    }

    public int update(Hr_emp emp){
        return this.empMapper.updateById(emp);

    }
    //根据empName查询
    public List<Hr_emp> getByEmpName(String empName){
        return empMapper.getByEmpName(empName);
    }

    public int save(Hr_emp emp){
        return this.empMapper.insert(emp);
    }
    public Integer delete(String empId,String empState){
        String[]arr=empId.split(",");
        int j=0;
        for (int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
            empMapper.updatestate(Integer.parseInt(arr[i]));
            j++;
        }
        if(j>0){
            return 1;
        }else{
            return 0;
        }
    }

    public Integer count(){
        QueryWrapper<Hr_emp> queryWrapper = new QueryWrapper<>();
        return this.empMapper.selectList(queryWrapper).size();
    }


    public List<Hr_emp> selectList(){
        return empMapper.selectList();
    }

    //w+
    public List<Hr_emp> empquery(){
        return empMapper.empquery();
    }
    public List<Hr_emp> empfy(String empname){
        return empMapper.empfy(empname);
    }
    //w+
    public List<Hr_emp> empfruyy(String empname){
        return empMapper.empfruyy(empname);
    }

    //f+
    public List<Hr_emp> getByName(){return empMapper.getByName();}
}
